-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update autocontrast #2317
Update autocontrast #2317
Conversation
Reviewer's Guide by SourceryThe pull request modifies the auto contrast function to allow for a cutoff and ignore parameters, and adds a method parameter to select between 'cdf' and 'pil' methods. It also adds new tests for the auto contrast function. Class diagram for updated AutoContrast transformclassDiagram
class AutoContrast {
+float cutoff
+int|None ignore
+str method
+float p
+__init__(cutoff: float, ignore: int|None, method: str, p: float)
+apply(img: ndarray) -> ndarray
+apply_to_images(images: ndarray) -> ndarray
+apply_to_volume(volume: ndarray) -> ndarray
+apply_to_volumes(volumes: ndarray) -> ndarray
+get_transform_init_args_names() -> tuple
}
note for AutoContrast "New parameters added:
- cutoff: % of pixels to exclude
- ignore: value to preserve
- method: 'cdf' or 'pil'"
Flow diagram for enhanced auto_contrast functionflowchart TD
A[Start auto_contrast] --> B{Check image channels}
B -->|Multi-channel| C[Pre-compute histograms]
B -->|Single channel| D[Compute histogram]
C --> E[Process each channel]
D --> E
E --> F{Check ignore value}
F -->|Has ignore value| G[Skip ignored channel]
F -->|No ignore value| H[Get histogram bounds]
H --> I{Check cutoff}
I -->|Has cutoff| J[Calculate bounds with cutoff]
I -->|No cutoff| K[Use min/max non-zero values]
J --> L[Create contrast LUT]
K --> L
L --> M{Select method}
M -->|CDF method| N[Apply CDF-based scaling]
M -->|PIL method| O[Apply linear scaling]
N --> P[Apply LUT to channel]
O --> P
P --> Q[Return enhanced image]
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @ternaus - I've reviewed your changes and they look great!
Here's what I looked at during the review
- 🟢 General issues: all looks good
- 🟢 Security: all looks good
- 🟢 Testing: all looks good
- 🟢 Complexity: all looks good
- 🟢 Documentation: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Summary by Sourcery
Improve the
auto_contrast
function by adding parameters for cutoff, ignore value, and method selection. Add tests for the new functionality and helper functions.New Features:
cutoff
parameter to control the percentage of pixels to cut off from the histogram edges.Tests:
auto_contrast
function, including edge cases and numerical stability.